﻿@if (ViewBag.Dp["Column"] != null)
{
<table class="GridViewTable" id="dgridTb">
    @if(ViewBag.Dp["HeaderHtml"]!=""){
        @Html.Raw(ViewBag.Dp["HeaderHtml"])
    }else{
    <tr class="GridViewHeader" onselectstart="return false">
        @if (ViewBag.isCheck != "0")
        {
            <td class="GridViewCheckBox"><input type="checkbox" onclick="SelectAllRows(this.checked);" title="选择所有行" /></td>
        }
        @foreach (var column in ViewBag.Dp["Column"])
        {
            <td class="GridViewHeaderField" id="@column.Key" nowrap>
                <font style="@column.Value[1]">@column.Value[0]</font>
                @if (ViewBag.Dp["OrderField"] == column.Key)
                {
                    if (ViewBag.Dp["OrderType"] == 0)
                    {<img src='../Images/btn/column_up.gif'>}
                    else if (ViewBag.Dp["OrderType"] == 1)
                    {<img src='../Images/btn/column_down.gif'>}
                }

            </td>
        }
    </tr>
    }
    @for (int i = 0; i < ViewBag.Dp["Data"].Rows.Count; i++)
    {
        var data = ViewBag.Dp["Data"].Rows[i];
        var k = i % 2;

    <tr class="GridViewRow GridViewRow_@k" id="GridViewRow_@data[ViewBag.Dp["KeyFieldName"]]" keyValue="@data[ViewBag.Dp["KeyFieldName"]]" keyCode="@ViewBag.Dp["KeyCode"][data[ViewBag.Dp["KeyFieldName"]]]" title="@(ViewBag.Dp["TextField"]!=""?ViewBag.Dp["TextField"]:"")">
        @if (ViewBag.isCheck != "0")
        {
            <td class="GridViewCheckBox"><input class="GridViewSelectCheckBox" type="checkbox" onclick="SelectRow('@data[ViewBag.Dp["KeyFieldName"]]',this);" value="@data[ViewBag.Dp["KeyFieldName"]]" /></td>
        }
        @foreach (var column in ViewBag.Dp["Column"])
        {

            if (data[column.Key].ToString().Length == 0)
            {
                <td style="text-align:@column.Value[2]" nowrap>@data[column.Key]</td>
            }
            else if (data[column.Key].ToString().Substring(0, 1) != "<")
            {
                if (data[column.Key].ToString().Length > 30)
                {
                    <td style="text-align:@column.Value[2]" title="@data[column.Key]" nowrap>@data[column.Key].ToString().Substring(0, 30)>>></td>
                }
                else
                {
                    <td style="text-align:@column.Value[2]" nowrap>@data[column.Key]</td>
                }
            }
            else if (data[column.Key].ToString().Substring(0, 1) == "<")
            {
                < td style = "text-align:@column.Value[2]" nowrap > @data[column.Key] </ td >
            }
        }
    </tr>
    }

    @if (ViewBag.Dp["SumPara"].Count > 0)
    {
    <tr class="GridViewFooter">
        @if (ViewBag.isCheck != 0)
        {
            <td>合计</td>
        }

        @{
            var i = 0;
            foreach(var dr in ViewBag.Dp["Column"])
            {
                <td style="text-align:@dr.Value[2]">
                    @if (ViewBag.isCheck == 0 && i++ == 0)
                    {
                        @Html.Raw("合计:")
                    }
                    @if (ViewBag.Dp["SumPara"].ContainsKey(dr.Key))
                    {
                        @ViewBag.Dp["SumPara"][dr.Key]
                    }
                </td>
            }
        }
    </tr>
    }
</table>
}
@if(ViewBag.Dp["RowCount"]!=-1)
{
    <script>
        PageSize = @ViewBag.Dp["PageSize"];
        RowCount = @ViewBag.Dp["RowCount"];
    </script>
}

